package com.wyman.test.bean2;



import com.wyman.beans.factory.annotation.Autowired;
import com.wyman.beans.factory.annotation.Value;
import com.wyman.stereotype.Component;

import java.util.Random;

@Component
public class UserService implements IUserService {

    @Value("${token}")
    private String token;

    @Autowired
    private UserDao userDao;


    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    public String queryUserInfo() {
//        try {
//            Thread.sleep(new Random(1).nextInt(100));
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
        if(userDao==null){
            System.out.println("没注入进来");
        }
        return userDao.queryUserName("10001") + token;
    }

    public String register(String userName) {
        return "注册用户：" + userName + " success！";
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

}
